--
-- Author: mm
-- Date: 2018-09-22 10:59:30
--
-- CorepropRender
--

local PropDescRender = app.mvc.createRenderClass(...)
local CorePropUIHelp = require("app.coreProp.CorePropUIHelp")
--data 
function PropDescRender.create(node)
    local sprite = PropDescRender.extend(node)
    if node == nil then
        ccui.Helper:doLayout(sprite)
    end
    sprite:init()
    return sprite
end

function PropDescRender:init()
    self.super.init(self, nil) 
    
end

function PropDescRender:setAlpha()
    local opacity = 150
    for i = 1, 3 do
        self._ui["Panel/data_"..i]:setOpacity(opacity)
    end
    self._ui["Panel/tlt"]:setOpacity(opacity)
    self._ui["Panel/num"]:setOpacity(opacity)
    self._ui["Panel/bg1"]:setOpacity(opacity)
end

function PropDescRender:refresh()
    if not self._data then
        return
    end
    local d = self._data
    self._ui["Panel/icon"]:loadTexture(CorePropUIHelp.getIconByType(d.type), ccui.TextureResType.plistType)
    -- self._ui["Panel/tlt"]:setString(string.format(L("CorePorpDescTitle"), CorePropUIHelp.getTextByType(d.type))) 
    
    self._ui["Panel/num"]:setString(string.format(L("CorePorpUnit"), d.level))

    local isGet, descStrArr = CorePropUIHelp.getPorpDescArr(d.type, d.level)
    for i = 1, 3 do
        if descStrArr[i] then
            self._ui["Panel/data_"..i]:setVisible(true)
            self._ui["Panel/data_"..i]:setString(descStrArr[i])
        else
            self._ui["Panel/data_"..i]:setVisible(false)
        end 
    end
    
end


function PropDescRender:setTitle(str)
    self._ui["Panel/tlt"]:setString(str) 
end


return PropDescRender
